package com.example.service.impl;

import com.example.mapper.auditProblemListMapp;
import com.example.pojo.auditProblemListPojo;
import com.example.service.auditProblemListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * ClassName:auditProblemListImpl
 * Package:com.example.service.impl
 * Description:
 *
 * @Author：牧星苑
 * @Create 2025/9/20 14:02
 * @Version 1.0
 */
@Service
public class auditProblemListImpl implements auditProblemListService {
    @Autowired
    private auditProblemListMapp auditProblemListMapp;
    //新增一条审核问题
    public void insertOne(auditProblemListPojo pojo){
        pojo.setCreate_time(LocalDateTime.now());
        pojo.setUpdate_time(LocalDateTime.now());
        auditProblemListMapp.insertOne(pojo);
    }

    //编辑一条审核问题
    public void editOneById(auditProblemListPojo pojo){
        pojo.setUpdate_time(LocalDateTime.now());
        auditProblemListMapp.editOneById(pojo);
    }

    //分页查询审核问题
    public List<auditProblemListPojo> queryByPage(Map<String, Object> map){
        Integer page =(Integer) map.get("page");
        Integer size=(Integer) map.get("size");
        Integer startRow=page*size;
        List<auditProblemListPojo> auditProblemListPojos=auditProblemListMapp.queryByPage(startRow, size);
        return auditProblemListPojos;
    }

    //查询所有审核问题条数
    public Integer queryQuantity(){
        Integer quantity= auditProblemListMapp.queryQuantity();
        return quantity;
    }

    //根据id修改一个字段
    public void editOneField(String id, String fieldName, String fieldValue){
        LocalDateTime update_time = LocalDateTime.now();
        auditProblemListMapp.editOneField(id, fieldName, fieldValue, update_time);
    }
}
